﻿/* File Created: April 1, 2013 */
$(document).ready(function () {
    $.datepicker.setDefaults($.datepicker.regional[""]);
    $(".datepicker").datepicker($.datepicker.regional["es"]);    
    $("#locale").change(function () {
        $(".datepicker").datepicker("option",
        $.datepicker.regional[$(this).val()]);
    });
});

//ESTE METODO DESHABILITA LOS CAMPOS DE UN FORMULARIO
function DisableEditControls(container) {
    $('input[type="text"]', container).attr('disabled', 'disabled');
    $('input[type="date"]', container).attr('disabled', 'disabled');
    $('input[type="checkbox"]', container).attr('disabled', 'disabled');
    $('textarea', container).attr('disabled', 'disabled');
    $('select', container).attr('disabled', 'disabled');

    $(".dateInput").datepicker("option", "showOn", "focus");
}

//formatter para poner un link con imagen en jqGRid. 
//Ej: { index: 'edit', formatter: imgLinkFormater, width: '10', linkUrl: '@Url.Action("AsignaAnalista")/', imgSrc: '@Url.Content("~/content/img/icon_modify.gif")'}
function imgLinkFormater(cellvalue, options, rowObject) {
    return "<a href='" + options.colModel.linkUrl + options.rowId + "'><img alt='edit' src='" + options.colModel.imgSrc + "'></a>";
};

function SendAjax(type, async, urlMethod, jsonData, FunctionSuccess, FunctionComplete) {
    $.ajax({
        type: type,
        url: urlMethod,
        data: jsonData,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        timeout: 30000,
        async: async,
        cache: false,
        success: FunctionSuccess,
        complete: FunctionComplete
    });
}

function BlockScreen(message) {
    $.blockUI({
        fadeIn: 0,
        fadeOut: 500,
        theme: true,
        title: (message !== undefined) ? message : 'Guardando datos',
        message: '<div><img src=' + '../Content/img/ajax.gif' + ' />  Aguarde un momento por favor...</div>',
        themedCSS: {
            height: '60px',
            width: '300px',
            top: ($(window).height() - 60) / 2 + 'px',
            left: ($(window).width() - 300) / 2 + 'px'
        }
    });
}